﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Collision.Shapes;
using FarseerPhysics.Factories;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace chemicall
{
    class PhysicalEntity : Sprite
    {
        //consts
        /*--Physics--*/
        public const float DEFAULT_FRICTION = 0.3f;

        /*--BOUNDS--*/
        public const int WALKABLE_MIN_ID = 100;

        protected Body body;
        protected Fixture bodyFixture;
        
        public void LoadContent(ContentManager contentManager, World world, String assetName, Vector2 position, Nullable<Rectangle> entitySize, Nullable<Rectangle> spriteSize, Sprite id)
        {
            base.LoadContent(contentManager, assetName, entitySize, spriteSize);
            body = BodyFactory.CreateBody(world, new Vector2(position.X, position.Y));
            body.Friction = DEFAULT_FRICTION;
            body.SleepingAllowed = true;
            body.UserData = id;
            PolygonShape bodyShape = new PolygonShape(1.0f);
            bodyShape.SetAsBox(this.entitySize.Width * 0.5f, this.entitySize.Height * 0.5f);
            bodyFixture = body.CreateFixture(bodyShape);
            Position = position;
        }

        public void Update(GameTime gameTime, Vector2 speed, Vector2 direction)
        {
            base.Update(gameTime, speed, direction);
        }
    }
}